package com.haojin.java;

/**
 * @author .29.
 * @create 2022-04-05 10:04
 */
public class SeasonTest1 {
    public static void main(String[] args) {
        //toString();
        Season1 summer = Season1.SUMMER;
        System.out.println(summer);
        System.out.println("*****************");
        //values()
        Season1[] values = Season1.values();
        for (int i = 0; i < values.length; i++) {
            System.out.println(values[i]);
        }
        System.out.println("*****************");
        //valueOf(String objName)：返回枚举类中对象名时objName的对象
        Season1 summer1 = Season1.valueOf("SUMMER");
        System.out.println(summer1);

        summer1.show();
        Season1.SPRING.show();
        Season1.AUTUMN.show();
        Season1.WINTER.show();
    }
}

interface info{
    void show();
}

//使用 enum 关键字，定义枚举类
//说明：定义的枚举类默认据称与java.lang.Enum类
enum Season1 implements info{
    //提供当前枚举类的对象，多个对象之间使用“，”隔开
    SPRING ("春天","春暖花开"){
        @Override
        public void show() {
            System.out.println("春天在哪里？");
        }
    },
    SUMMER("夏天","夏日炎炎"){
        @Override
        public void show() {
            System.out.println("悄悄夏天，悄悄过去，留下小秘密。。。");
        }
    },
    AUTUMN("秋天","秋高气爽"){
        @Override
        public void show() {
            System.out.println("那年秋天");
        }
    },
    WINTER("冬天","冰天雪地"){
        @Override
        public void show() {
            System.out.println("下雪，堆雪人");
        }
    };

    //声明Season对象的属性
    private final String seasonName;
    private final String seasonDesc;

    //1.私有化类的构造器
    private Season1(String seasonName,String seasonDesc){
        this.seasonDesc = seasonDesc;
        this.seasonName = seasonName;
    }



    //4.其他诉求1：获取枚举类对象的属性
    public String getSeasonName() {
        return seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }

    //4.其他诉求2：toString()

//    @Override
//    public String toString() {
//        return "Season1{" +
//                "seasonName='" + seasonName + '\'' +
//                ", seasonDesc='" + seasonDesc + '\'' +
//                '}';
//    }


//    @Override
//    public void show() {
//        System.out.println("这是一个季节");
//    }
}